<!DOCTYPE html>
<html>

	<head>
			<include file="Public/head" />
		<title>注册--{$config['store_name']}</title>
	</head>
	<style>
		body {
			background: #e5e5e5 url(__STATIC__/images/login_b.jpg) no-repeat center fixed;
		}
	</style>

	<body>
		<!-- BEGIN 正式页面 -->
		<div class="loregbox ">
			<div class="loregbox_in  loregbox_in_new loregbox_in_new_reg">
				<div class="loginbox clearfix">
					<div class="l_logo">
						<a href="{:U('Index/index')}" title="返回首页" name="login-logo"><img src="{$config['store_logo']}"></a>
					</div>
					<div class="formleft tan_p">
						<!--注册-->
						<h2>注册<span><a href="{:U('login')}"  name="register-lijidenglu">立即登录&gt;</a></span></h2>
						<form id="register">

							<!--	<h4>手机注册时输入邀请码送金币，金币可抵现金</h4>-->
							<div class="forminput">
								<input name="username" type="text" id="username" placeholder="用户名" autocomplete="OFF" class="valifytext" onblur="checkrule(this)">
								<span class="duihao" style="display: none"></span>
								<span class="wrong" id="username_msg" style="display: none">用户名不能为空</span>
							</div>
							<!-- <div class="regist_qie"> -->
							<!-- <a href="?reg_type=2" name="youxiangzhuce">使用邮箱注册</a> -->
							<!-- </div> -->
							<div class="forminput">
								<input id="password" name="password" type="password" placeholder="密码" autocomplete="OFF" class="valifytext" maxlength="18" onblur="checkrule(this)">
								<span class="duihao" style="display: none"></span>
								<span class="wrong" style="display: none">密码不能为空</span>
							</div>
							<div class="forminput">
								<input id="confirm_password" name="confirm_password" type="password" placeholder="确认密码" autocomplete="OFF" class="valifytext" maxlength="18" onblur="checkrule(this)">
								<span class="duihao" style="display: none"></span>
								<span class="wrong" style="display: none">两次密码必须相同</span>
							</div>
							<!--邮箱-->
							<!--手机-->
							<div class="yzmbox clearfix">
								<input name="checkcode" type="text" placeholder="验证码" autocomplete="OFF" class="valifytext" id="checkcode" maxlength="4">
								<span style="border:1px #CCC solid;height: 33px;"><img src="{:U('User/getcode')}" id="refucaptcha" width="102" height="38"></span>
								<span>看不清？<a href="javascript:changecode()" class="_jsrefucaptcha" style="color: #1fb6c4;">换一张</a></span>
								<div class="clear"></div>
							</div>
							<!--<div class="duanxinbox clearfix">
								<span class="yanzheng" id="djs_tel">免费发送验证码</span>
								<input name="vcode" type="text" placeholder="验证码" class="valifytext" id="vcode">
								<div class="clear"></div>
							</div>-->
							<!--<span class="wrong" style="display: none;width:215px;" id="code_msg"></span>
							<span class="wrong" id="mobile_msg" style="display: none">请填写正确的手机号</span>-->
							<!--手机end-->
							<!--<div class="forminput">
								<input type="text" name="invitecode" placeholder="输入5位邀请码（非必填）" class="valifytext" id="invitecode">
								<span class="wrong" style="display: none" id="icode_msg"></span>
							</div>-->
							<div class="formbtn">
								<div value="注册" class="submit_btn" onclick="register_ajax();" style="margin-top: 50px;">注册</div>
							</div>
						</form>
						<!--注册end-->
						<!--合作登录-->
						<!--<div class="hezuo">
							<div class="line_hezuo">
								<h4 class="tc">使用合作账号快速登录</h4>
							</div>
							<div class="b_hezuo">
								<a href="javascript:;" id="qq_login" name="qq-denglu"><img src="http://static.uthing.cn/images-2.1/login/qq.jpg">&nbsp;QQ</a>
								<a href="javascript:;" id="wb_login" name="weibo-denglu"><img src="http://static.uthing.cn/images-2.1/login/weibo.jpg">&nbsp;微博</a>
								<a href="javascript:;" id="wx_login"><img src="http://static.uthing.cn/images-2.1/login/weixin.jpg">&nbsp;微信</a>
							</div>
					
						</div>-->
						<!--合作登录end-->
					</div>
				</div>
			</div>
		</div>

		<script>
			var errorcount = 0;
			var iseq = false;

			function register_ajax() {

				//				if(checkisEmpty('#password')) {
				//					layer.alert('密码不能为空', {
				//						icon: 2
				//					});
				//					return;
				//				}
				$('.forminput>input').each(function() {

					checkrule(this);
				})

				if(errorcount > 0 || !iseq) {
					return;
				}
				if($('#checkcode').val() == "") {

					layer.alert('验证码不能为空', {
						icon: 2
					});
					return;
				}
				var index = layer.load(3);
				data = $("#register").serialize();
				var url = "{:U('User/register_ajax')}";

				ajax(url, 'post', data, register_back);

			}

			function register_back(data) {
				layer.closeAll('loading');
				if(data.status == 1) {
					layer.alert(data.msg, {
						icon: 1
					});
					window.location.href = data.url;
				} else {
					layer.alert(data.msg, {
						icon: 2
					});
					changecode();

				}
			}

			function changecode() {
				$('#refucaptcha').attr('src', '{:U("User/getcode")}');

			}

			function checkrule(obj) {
				if($(obj).attr('id') == "confirm_password") {
					if($(obj).val() != $('#password').val()) {
						$(obj).siblings().eq(1).show();
						iseq = 0;

						return;
					} else {

						iseq = 1;
						$(obj).siblings().eq(1).hide();
						$(obj).siblings().eq(0).show();
						return;
					}
				}
				if($(obj).val() == "") {

					$(obj).siblings().eq(1).show();

					errorcount = errorcount + 1;

				} else {

					$(obj).siblings().eq(1).hide();
					$(obj).siblings().eq(0).show();
					errorcount = errorcount - 1;

				}

			}
		</script>
	</body>

</html>